#include <srts/stratego.h>
#include <stratego-lib/stratego-lib.h>
void init_constructors (void)
{
}
static Symbol sym__3;
static Symbol sym__2;
static Symbol sym_Nil_0;
static Symbol sym_Cons_2;
static Symbol sym_Var_1;
static Symbol sym_Int_1;
static Symbol sym_Str_1;
static Symbol sym_Op_2;
static Symbol sym_RootApp_1;
static Symbol sym_SVar_1;
static Symbol sym_Id_0;
static Symbol sym_Seq_2;
static Symbol sym_Call_2;
static Symbol sym_BA_2;
static Symbol sym_Where_1;
static Symbol sym_AM_2;
static Symbol sym_SDefNoArgs_2;
static Symbol sym_SDef_3;
static Symbol sym_RuleNoCond_2;
static Symbol sym_Rule_3;
static void init_module_constructors (void)
{
sym__3 = ATmakeSymbol("", 3, ATfalse);
ATprotectSymbol(sym__3);
sym__2 = ATmakeSymbol("", 2, ATfalse);
ATprotectSymbol(sym__2);
sym_Nil_0 = ATmakeSymbol("Nil", 0, ATfalse);
ATprotectSymbol(sym_Nil_0);
sym_Cons_2 = ATmakeSymbol("Cons", 2, ATfalse);
ATprotectSymbol(sym_Cons_2);
sym_Var_1 = ATmakeSymbol("Var", 1, ATfalse);
ATprotectSymbol(sym_Var_1);
sym_Int_1 = ATmakeSymbol("Int", 1, ATfalse);
ATprotectSymbol(sym_Int_1);
sym_Str_1 = ATmakeSymbol("Str", 1, ATfalse);
ATprotectSymbol(sym_Str_1);
sym_Op_2 = ATmakeSymbol("Op", 2, ATfalse);
ATprotectSymbol(sym_Op_2);
sym_RootApp_1 = ATmakeSymbol("RootApp", 1, ATfalse);
ATprotectSymbol(sym_RootApp_1);
sym_SVar_1 = ATmakeSymbol("SVar", 1, ATfalse);
ATprotectSymbol(sym_SVar_1);
sym_Id_0 = ATmakeSymbol("Id", 0, ATfalse);
ATprotectSymbol(sym_Id_0);
sym_Seq_2 = ATmakeSymbol("Seq", 2, ATfalse);
ATprotectSymbol(sym_Seq_2);
sym_Call_2 = ATmakeSymbol("Call", 2, ATfalse);
ATprotectSymbol(sym_Call_2);
sym_BA_2 = ATmakeSymbol("BA", 2, ATfalse);
ATprotectSymbol(sym_BA_2);
sym_Where_1 = ATmakeSymbol("Where", 1, ATfalse);
ATprotectSymbol(sym_Where_1);
sym_AM_2 = ATmakeSymbol("AM", 2, ATfalse);
ATprotectSymbol(sym_AM_2);
sym_SDefNoArgs_2 = ATmakeSymbol("SDefNoArgs", 2, ATfalse);
ATprotectSymbol(sym_SDefNoArgs_2);
sym_SDef_3 = ATmakeSymbol("SDef", 3, ATfalse);
ATprotectSymbol(sym_SDef_3);
sym_RuleNoCond_2 = ATmakeSymbol("RuleNoCond", 2, ATfalse);
ATprotectSymbol(sym_RuleNoCond_2);
sym_Rule_3 = ATmakeSymbol("Rule", 3, ATfalse);
ATprotectSymbol(sym_Rule_3);
}
static ATerm term25;
static ATerm term24;
static ATerm term23;
static ATerm term22;
static ATerm term21;
static ATerm term20;
static ATerm term19;
static ATerm term18;
static ATerm term17;
static ATerm term16;
static ATerm term15;
static ATerm term14;
static ATerm term13;
static ATerm term12;
static ATerm term11;
static ATerm term10;
static ATerm term9;
static ATerm term8;
static ATerm term7;
static ATerm term6;
static ATerm term5;
static ATerm term4;
static ATerm term3;
static ATerm term2;
static ATerm term1;
static ATerm term0;
static void init_module_constant_terms (void)
{
ATprotect(&(term0));
term0 = (ATerm) ATmakeAppl(ATmakeSymbol("table-get", 0, ATtrue));
ATprotect(&(term1));
term1 = term0;
ATprotect(&(term2));
term2 = (ATerm) ATmakeAppl(sym_SVar_1, term1);
ATprotect(&(term3));
term3 = term2;
ATprotect(&(term4));
term4 = (ATerm) ATmakeAppl(sym_Call_2, term3, (ATerm) ATempty);
ATprotect(&(term5));
term5 = term4;
ATprotect(&(term6));
term6 = (ATerm) ATmakeAppl(ATmakeSymbol("index", 0, ATtrue));
ATprotect(&(term7));
term7 = term6;
ATprotect(&(term8));
term8 = (ATerm) ATmakeAppl(sym_SVar_1, term7);
ATprotect(&(term9));
term9 = term8;
ATprotect(&(term10));
term10 = (ATerm) ATmakeAppl(sym_Call_2, term9, (ATerm) ATempty);
ATprotect(&(term11));
term11 = term10;
ATprotect(&(term12));
term12 = (ATerm) ATmakeAppl(ATmakeSymbol("", 0, ATtrue));
ATprotect(&(term13));
term13 = term12;
ATprotect(&(term14));
term14 = (ATerm) ATmakeAppl(sym_Id_0);
ATprotect(&(term15));
term15 = term14;
ATprotect(&(term16));
term16 = (ATerm) ATmakeAppl(sym_RootApp_1, term15);
ATprotect(&(term17));
term17 = term16;
ATprotect(&(term18));
term18 = (ATerm) ATmakeAppl(ATmakeSymbol("arguments", 0, ATtrue));
ATprotect(&(term19));
term19 = term18;
ATprotect(&(term20));
term20 = (ATerm) ATmakeAppl(sym_Str_1, term19);
ATprotect(&(term21));
term21 = term20;
ATprotect(&(term22));
term22 = (ATerm) ATmakeAppl(ATmakeSymbol("pepci-global", 0, ATtrue));
ATprotect(&(term23));
term23 = term22;
ATprotect(&(term24));
term24 = (ATerm) ATmakeAppl(sym_Str_1, term23);
ATprotect(&(term25));
term25 = term24;
}
#include <srts/init-stratego-application.h>
extern const char * __tracing_table [];
extern unsigned short __tracing_table_counter;
ATerm env_alltd_1_0 (StrSL sl, StrCL y_32, ATerm t);
ATerm io_wrap_1_0 (StrSL sl, StrCL h_26, ATerm t);
ATerm ReplaceStrategoArgument_0_0 (StrSL sl, ATerm t);
static ATerm lifted0 (StrSL sl, ATerm t);
ATerm main_0_0 (StrSL sl, ATerm t);
ATerm ReplaceStrategoArgument_0_0 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "ReplaceStrategoArgument_0_0";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
{
ATerm trm0 = t;
ATerm o_9 = NULL,p_9 = NULL,q_9 = NULL,r_9 = NULL,s_9 = NULL;
if(match_cons(t, sym__2))
{
ATerm trm1 = ATgetArgument(t, 0);
if(match_cons(trm1, sym_SDef_3))
{
o_9 = ATgetArgument(trm1, 0);
p_9 = ATgetArgument(trm1, 1);
s_9 = ATgetArgument(trm1, 2);
}
else
goto label1 ;
{
ATerm trm2 = ATgetArgument(t, 1);
if(match_cons(trm2, sym__2))
{
r_9 = ATgetArgument(trm2, 0);
q_9 = ATgetArgument(trm2, 1);
}
else
goto label1 ;
}
}
else
goto label1 ;
t = (ATerm) ATmakeAppl(sym_SDef_3, o_9, p_9, (ATerm) ATmakeAppl(sym_Seq_2, (ATerm)ATmakeAppl(sym_Where_1, (ATerm) ATmakeAppl(sym_AM_2, (ATerm)ATmakeAppl(sym_BA_2, (ATerm)ATmakeAppl(sym_Seq_2, term5, (ATerm) ATmakeAppl(sym_BA_2, term11, (ATerm) ATmakeAppl(sym_Op_2, term13, (ATerm) ATinsert(ATinsert(ATempty, term17), (ATerm) ATmakeAppl(sym_Int_1, q_9))))), (ATerm) ATmakeAppl(sym_Op_2, term13, (ATerm) ATinsert(ATinsert(ATempty, term21), term25))), (ATerm) ATmakeAppl(sym_Var_1, r_9))), s_9));
goto label0 ;
label1 :
t = trm0;
{
ATerm trm3 = t;
ATerm k_9 = NULL,l_9 = NULL,m_9 = NULL,n_9 = NULL;
if(match_cons(t, sym__2))
{
ATerm trm4 = ATgetArgument(t, 0);
if(match_cons(trm4, sym_SDefNoArgs_2))
{
k_9 = ATgetArgument(trm4, 0);
n_9 = ATgetArgument(trm4, 1);
}
else
goto label2 ;
{
ATerm trm5 = ATgetArgument(t, 1);
if(match_cons(trm5, sym__2))
{
m_9 = ATgetArgument(trm5, 0);
l_9 = ATgetArgument(trm5, 1);
}
else
goto label2 ;
}
}
else
goto label2 ;
t = (ATerm) ATmakeAppl(sym_SDefNoArgs_2, k_9, (ATerm) ATmakeAppl(sym_Seq_2, (ATerm)ATmakeAppl(sym_Where_1, (ATerm) ATmakeAppl(sym_AM_2, (ATerm)ATmakeAppl(sym_BA_2, (ATerm)ATmakeAppl(sym_Seq_2, term5, (ATerm) ATmakeAppl(sym_BA_2, term11, (ATerm) ATmakeAppl(sym_Op_2, term13, (ATerm) ATinsert(ATinsert(ATempty, term17), (ATerm) ATmakeAppl(sym_Int_1, l_9))))), (ATerm) ATmakeAppl(sym_Op_2, term13, (ATerm) ATinsert(ATinsert(ATempty, term21), term25))), (ATerm) ATmakeAppl(sym_Var_1, m_9))), n_9));
goto label0 ;
label2 :
t = trm3;
{
ATerm trm6 = t;
ATerm f_9 = NULL,g_9 = NULL,h_9 = NULL,i_9 = NULL,j_9 = NULL;
if(match_cons(t, sym__2))
{
ATerm trm7 = ATgetArgument(t, 0);
if(match_cons(trm7, sym_Rule_3))
{
f_9 = ATgetArgument(trm7, 0);
g_9 = ATgetArgument(trm7, 1);
j_9 = ATgetArgument(trm7, 2);
}
else
goto label3 ;
{
ATerm trm8 = ATgetArgument(t, 1);
if(match_cons(trm8, sym__2))
{
i_9 = ATgetArgument(trm8, 0);
h_9 = ATgetArgument(trm8, 1);
}
else
goto label3 ;
}
}
else
goto label3 ;
t = (ATerm) ATmakeAppl(sym_Rule_3, f_9, g_9, (ATerm) ATmakeAppl(sym_Seq_2, (ATerm)ATmakeAppl(sym_AM_2, (ATerm)ATmakeAppl(sym_BA_2, (ATerm)ATmakeAppl(sym_Seq_2, term5, (ATerm) ATmakeAppl(sym_BA_2, term11, (ATerm) ATmakeAppl(sym_Op_2, term13, (ATerm) ATinsert(ATinsert(ATempty, term17), (ATerm) ATmakeAppl(sym_Int_1, h_9))))), (ATerm) ATmakeAppl(sym_Op_2, term13, (ATerm) ATinsert(ATinsert(ATempty, term21), term25))), (ATerm) ATmakeAppl(sym_Var_1, i_9)), j_9));
goto label0 ;
label3 :
t = trm6;
{
ATerm b_9 = NULL,c_9 = NULL,d_9 = NULL,e_9 = NULL;
if(match_cons(t, sym__2))
{
ATerm trm9 = ATgetArgument(t, 0);
if(match_cons(trm9, sym_RuleNoCond_2))
{
b_9 = ATgetArgument(trm9, 0);
c_9 = ATgetArgument(trm9, 1);
}
else
goto fail2 ;
{
ATerm trm10 = ATgetArgument(t, 1);
if(match_cons(trm10, sym__2))
{
e_9 = ATgetArgument(trm10, 0);
d_9 = ATgetArgument(trm10, 1);
}
else
goto fail2 ;
}
}
else
goto fail2 ;
t = (ATerm) ATmakeAppl(sym_Rule_3, b_9, c_9, (ATerm) ATmakeAppl(sym_Seq_2, (ATerm)ATmakeAppl(sym_AM_2, (ATerm)ATmakeAppl(sym_BA_2, (ATerm)ATmakeAppl(sym_Seq_2, term5, (ATerm) ATmakeAppl(sym_BA_2, term11, (ATerm) ATmakeAppl(sym_Op_2, term13, (ATerm) ATinsert(ATinsert(ATempty, term17), (ATerm) ATmakeAppl(sym_Int_1, d_9))))), (ATerm) ATmakeAppl(sym_Op_2, term13, (ATerm) ATinsert(ATinsert(ATempty, term21), term25))), (ATerm) ATmakeAppl(sym_Var_1, e_9)), term15));
goto label0 ;
}
}
}
label0 :
;
}
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail2 :
--__tracing_table_counter;
return(NULL);
}
ATerm main_0_0 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "main_0_0";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
{
struct str_closure b_114 = { &(lifted0) , &(frame) };
StrCL lifted0_cl = &(b_114);
t = io_wrap_1_0(sl, lifted0_cl, t);
if((t == NULL))
goto fail0 ;
}
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail0 :
--__tracing_table_counter;
return(NULL);
}
static ATerm lifted0 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "lifted0";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
{
ATerm x_113 = NULL,y_113 = NULL,z_113 = NULL;
struct str_closure a_114 = { &(ReplaceStrategoArgument_0_0) , sl_up(sl) };
StrCL lifted1_cl = &(a_114);
if(match_cons(t, sym__3))
{
y_113 = ATgetArgument(t, 0);
z_113 = ATgetArgument(t, 1);
x_113 = ATgetArgument(t, 2);
}
else
goto fail1 ;
t = (ATerm) ATmakeAppl(sym__2, x_113, (ATerm) ATmakeAppl(sym__2, y_113, z_113));
t = env_alltd_1_0(sl_up(sl), lifted1_cl, t);
if((t == NULL))
goto fail1 ;
}
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail1 :
--__tracing_table_counter;
return(NULL);
}
static void register_strategies (void)
{
int initial_size = 117;
int max_load = 75;
struct str_closure * closures;
int closures_index = 0;
if((strategy_table == NULL))
strategy_table = ATtableCreate(initial_size, max_load);
closures = (struct str_closure*) malloc((sizeof(struct str_closure) * 5));
if((closures == NULL))
{
perror("malloc error for registration of dynamic strategies");
exit(1);
}
closures[closures_index].fun = &(env_alltd_1_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("env_alltd_1_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(io_wrap_1_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("io_wrap_1_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(ReplaceStrategoArgument_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("ReplaceStrategoArgument_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(lifted0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("lifted0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(main_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("main_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
}
int main (int argc, char * argv [])
{
ATerm out_term;
ATermList in_term;
int i;
ATinit(argc, argv, &(out_term));
init_constructors();
in_term = ATempty;
for ( i = (argc - 1) ; (i >= 0) ; i-- )
{
in_term = ATinsert(in_term, (ATerm) ATmakeAppl0(ATmakeSymbol(argv[i], 0, ATtrue)));
}
SRTS_stratego_initialize();
memset(__tracing_table, 0, (sizeof(unsigned short) * TRACING_TABLE_SIZE));
__tracing_table_counter = 0;
register_strategies();
out_term = main_0_0(NULL, (ATerm) in_term);
if((out_term != NULL))
{
ATfprintf(stdout, "%t\n", out_term);
exit(0);
}
else
{
ATfprintf(stderr, "%s: rewriting failed, trace:\n", argv[0]);
for ( i = 0 ; (__tracing_table[i] && (i < TRACING_TABLE_SIZE)) ; i++ )
ATfprintf(stderr, "\t%s\n", __tracing_table[i]);
exit(1);
}
}
